# import math
# from PIL import Image, ImageDraw, ImageFont
#
# # 读取图片
# image_path = 'C:\\Users\\kaifacs\\Downloads\\1.jpg'  # 替换为你的图片路径
# pil_image = Image.open(image_path)
#
# # 获取图像的宽度和高度
# width, height = pil_image.size
#
# # 创建一个绘图对象
# draw = ImageDraw.Draw(pil_image)
#
# # 定义两个点的坐标
# point1 = (324.8306579589844, height-451.3359680175781)
# point2 = (190.34872436523438, height-428.95977783203125)
# point3 = (0, 0)
#
# # 标注点
# draw.ellipse((point1[0] - 5, point1[1] - 5, point1[0] + 5, point1[1] + 5), fill="red")
# draw.ellipse((point2[0] - 5, point2[1] - 5, point2[0] + 5, point2[1] + 5), fill="blue")
# draw.ellipse((point3[0] - 5, point3[1] - 5, point3[0] + 5, point3[1] + 5), fill="green")
#
# # 绘制两点之间的连线
# draw.line([point1, point2], fill="green", width=2)
#
# # 绘制第一个点的水平线
# draw.line([(0, point1[1]), (width, point1[1])], fill="yellow", width=2)
#
# # 计算两个点连线的斜率
# dx = point2[0] - point1[0]
# dy = point2[1] - point1[1]
#
# # 计算夹角（弧度）
# angle_radians = math.atan2(dy, dx)
# print(f"angle_radians : {angle_radians}")
#
# # 转换为角度
# angle_degrees = math.degrees(angle_radians)
#
# # 打印夹角
# print(f"两条线之间的夹角为: {angle_degrees} 度")
#
#
# # 设置字体
# try:
#     font = ImageFont.truetype("arial.ttf", 20)
# except IOError:
#     font = ImageFont.load_default()
#
# # 在图上标注夹角
# text = f"{angle_degrees:.2f}°"
#
# # 计算文本的宽度和高度
# left, top, right, bottom = font.getbbox(text)
# text_width = right - left
# text_height = bottom - top
#
# # 确定文本位置
# text_position = (point1[0] + 10, point1[1] - text_height - 10)
#
# # 绘制文本
# draw.text(text_position, text, fill="black", font=font)
#
# # 显示图像
# pil_image.show()
#
# # 保存图像
# # pil_image.save('annotated_image.png')
#
#
